﻿<Window x:Class="Signum.Windows.SelectorWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:m="clr-namespace:Signum.Windows"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="SelectorWindow" 
    WindowStartupLocation="CenterOwner"
    SizeToContent="WidthAndHeight"
    TextOptions.TextFormattingMode="Display"
    UseLayoutRounding="True" 
    x:Name="win">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>
        <TextBlock x:Name="tb" Grid.Row="0" Margin="10,10,10,0" FontWeight="bold" Text="{Binding Message, ElementName=win}"/>
        <Border BorderThickness="1" BorderBrush="RoyalBlue" Margin="10" Grid.Row="1" CornerRadius="4" Padding="2">
            <ItemsControl x:Name="itemsControl" ItemsSource="{Binding Elements, ElementName=win}">
                <ItemsControl.ItemTemplate>
                    <DataTemplate>
                        <ToggleButton Checked="ToggleButton_Checked" Padding="3" AutomationProperties.ItemStatus="{Binding Element}">
                            <StackPanel Orientation="Horizontal">
                                <Image Source="{Binding Image}" VerticalAlignment="Center"/>
                                <TextBlock Text="{Binding Text}" FontSize="12" Margin="10,0" VerticalAlignment="Center"/>
                            </StackPanel>
                        </ToggleButton>
                    </DataTemplate>
                </ItemsControl.ItemTemplate>
                <ItemsControl.ItemContainerStyle>
                    <Style TargetType="{x:Type ContentPresenter}" >
                        <Setter Property="Margin" Value="4" />
                    </Style>
                </ItemsControl.ItemContainerStyle>
                <ItemsControl.Template>
                    <ControlTemplate>
                        <StackPanel Orientation="Vertical" IsItemsHost="True"/>
                    </ControlTemplate>
                </ItemsControl.Template>
            </ItemsControl>
        </Border>
    </Grid>
</Window>
